var windowName = "siteSteps";
apiready = function(){
    onWindowShow(function () {
        var cur = getLocData("curSite")
        Page.curSite = cur;
        getData(Page)
    })
    onWindowHide(function () {
    })
    console.log("index page is OK");
    var Page = createVM("#Page",{
        //页面数据
        curSite:{},
        curStep:0,
        steps:{},
        en:{id:0,status:0},


        zbdw:["张三","李四"],
        value1:"",
    },{
        //页面方法
        init:function () {
        }
        ,setCur:function (index) {
            this.curStep = index
        }
        ,goToNext:function () {
            var steps = this.steps;
            var cur = this.en.status
            var last = 0
            var step = 0
            for(var i  in steps){
                step++
                if (cur == last){
                    this.en.status = i
                    this.curStep = step
                    var param =createForm(this.en)
                    logJson(param)
                    apiPost("/app/site/status",param,function (res) {
                        logJson(res)
                    })
                    return
                }
                last = i
            }

        }
    })

    Page.init()

}
function getData(_this) {
    apiGet("/app/site/status",{id:_this.curSite.id},function (res) {
        logJson(res)
        _this.en =res.data.en
        _this.steps =res.data.steps
        var cur = _this.en.status
        var step = 0
        for(var i  in _this.steps){
            step++
            if (cur == i){
                _this.en.status = i
                _this.curStep = step
                return
            }
            last = i
        }
    })
}